package cn.geckos.fml.data
{
	import cn.geckos.fml.Type;
	import flash.utils.Dictionary;
	
	public class LinkData implements IData
	{
		
		private var _id:String;
		private var _name:String;
		private var _host:String;
		private var _map:Dictionary;
		
		
		public function LinkData()
		{
			_map = new Dictionary();
		}
		
		public function set id(id:String):void
		{
			this._id = id;
		}
		
		public function get id():String
		{
			return _id;
		}
		
		public function set name(name:String):void
		{
			this._name = name;
		}
		
		public function get name():String
		{
			return this._name;
		}
		
		public function set host(host:String):void
		{
			this._host = host;
		}
		
		public function get host():String
		{
			return this._host;
		}
		
		public function get type():String
		{
			return Type.LINK;
		}
		
		public function get parameters():Dictionary
		{
			return this._map;
		}
		
		public function setParam(key:Object, value:Object):void
		{
			this._map[String(key)] = value;
		}
		
		public function getParam(key:Object):Object
		{
			return this._map[String(key)];
		}
		
		public function equals(o:Object):Boolean
		{
			if(o == this)
			{
				return true;
			}else
			{
				if(o is LinkData)
				{
					var t:LinkData = o as LinkData;
					if(t.id == this._id && 
					   t.name == this._name && 
					   t.host == this._host)
					{
						for(var i:Object in t.parameters)
						{
							if(_map[i] != t.parameters[i]) return false;
						}
						for(var j:Object in _map)
						{
							if(_map[j] != t.parameters[j]) return false;
						}
						return true;
					}else
					{
						return false;
					}
				}else return false;
			}
		}
	}
}